import Controller from './Controller';

export default class LabelController extends Controller {

	constructor( parent, object, property, config ) {

		super( parent, object, property, 'label', 'div', config );

		if(config == null) config = {} ;

		this.$p = document.createElement( 'p' );
		this.$p.classList.add("labelp") ;

		this.$widget.appendChild( this.$p );

		this._appendEndDomHtml(config.endHtml) ;
		// let endHtml = config.endHtml ;
		// if(endHtml != null && endHtml != ""){
		// 	this.$span = document.createElement( 'span' );
		// 	this.$span.classList.add("lilInlineEndSpan") ;
		// 	this.$widget.appendChild( this.$span );
		//
		// 	this.$span.innerHTML = endHtml ;
		// }


		this.$disable = this.$p;

		this.updateDisplay();

	}

	updateDisplay() {
		this.$p.innerHTML = this.getValue();
		return this;
	}

	setStyle(style){
		if(style == null || style == "") return this ;
		if(this.$p == null) return this;
		this.$p.setAttribute("style",style) ;
		return this ;
	}

	addClass(clazz){
		if(clazz == null || clazz == "") return this ;
		if(this.$p == null) return this;
		this.$p.classList.add(clazz) ;
		return this ;
	}

	removeClass(clazz){
		if(clazz == null || clazz == "") return this;
		if(this.$p == null) return this;
		this.$p.classList.remove(clazz) ;
		return this ;
	}

}
